﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="Tours.aspx.cs" Inherits="SampleIntermediateASPExam2.Tours" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<%--   <link href="Styles/Site.css" rel="stylesheet" type="text/css" />--%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
    <asp:EntityDataSource ID="DestinationsDataSource" runat="server" ConnectionString="name=TravelAgencyDatabaseEntities"
                          DefaultContainerName="TravelAgencyDatabaseEntities" EnableDelete="True" EnableFlattening="False"
                          EnableInsert="True" EnableUpdate="True" EntitySetName="Destinations">
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="TransportationsDataSource" runat="server" ConnectionString="name=TravelAgencyDatabaseEntities"
                          DefaultContainerName="TravelAgencyDatabaseEntities" EnableDelete="True" EnableFlattening="False"
                          EnableInsert="True" EnableUpdate="True" EntitySetName="Transportations">
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="BoardsDataSource" runat="server" ConnectionString="name=TravelAgencyDatabaseEntities"
                          DefaultContainerName="TravelAgencyDatabaseEntities" EnableDelete="True" EnableFlattening="False"
                          EnableInsert="True" EnableUpdate="True" EntitySetName="Boards">
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="FacilitiesDataSource" runat="server" ConnectionString="name=TravelAgencyDatabaseEntities"
                          DefaultContainerName="TravelAgencyDatabaseEntities" EnableDelete="True" EnableFlattening="False"
                          EnableInsert="True" EnableUpdate="True" EntitySetName="Facilities">
    </asp:EntityDataSource>
    <asp:ListView ID="ToursListView" runat="server" DataSourceID="TravelAgencyDateSource"
                  DataKeyNames="TourID" InsertItemPosition="LastItem" OnItemEditing="EditTour">
        <EditItemTemplate>
            <tr style="background-color: #008A8C; color: #FFFFFF;">
                <td>
                    <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
                </td>
                <td>
                    <asp:Label runat="server" ID="TourIDLabel" Text='<%# Eval("TourID") %>' Visible="false"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList runat="server" ID="DestinationDropDownList" DataSourceID="DestinationsDataSource"
                                      DataTextField="DestinationName" DataValueField="DestinationID" SelectedValue='<%# Bind("DestinationID") %>'>
                    </asp:DropDownList>
                </td>
                <td>
                    <asp:TextBox ID="StartDateTextBox" runat="server" Text='<%# Bind("StartDate") %>' />
                    <asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="StartDateTextBox">
                    </asp:CalendarExtender>
                </td>
                <td>
                    <asp:TextBox ID="EndDateTextBox" runat="server" Text='<%# Bind("EndDate") %>' />
                    <asp:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="EndDateTextBox">
                    </asp:CalendarExtender>
                </td>
                <td>
                    <asp:TextBox ID="PriceTextBox" runat="server" Text='<%# Bind("Price") %>' />
                </td>
                <td>
                    <asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
                </td>
                <td>
                    <asp:DropDownList runat="server" ID="TransportsDropDownList" DataSourceID="TransportationsDataSource"
                                      DataValueField="TransportID" DataTextField="TransportName" SelectedValue='<%# Bind("TransportationID") %>'>
                    </asp:DropDownList>
                </td>
                <td>
                    <asp:TextBox ID="BoardIDTextBox" runat="server" Text='<%# Bind("BoardID") %>' />
                </td>
                <td>
                    <asp:CheckBoxList ID="FacilitiesCheckBoxList" runat="server" DataSourceID="FacilitiesDataSource"
                                      DataTextField="FacilityName" DataValueField="FacilityID" OnDataBound="FacilitiesCheckBoxList_OnDataBound">
                    </asp:CheckBoxList>
                </td>
            </tr>
        </EditItemTemplate>
        <EmptyDataTemplate>
            <table runat="server" style="background-color: #FFFFFF; border-collapse: collapse;
                   border-color: #999999; border-style: none; border-width: 1px;">
                <tr>
                    <td>
                        No data was returned.
                    </td>
                </tr>
            </table>
        </EmptyDataTemplate>
        <InsertItemTemplate>
            <tr style="">
                <td>
                    <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
                </td>
                <td>
                    <asp:TextBox ID="TourIDTextBox" runat="server" Text='<%# Bind("TourID") %>' />
                </td>
                <td>
                    <asp:TextBox ID="DestinationIDTextBox" runat="server" Text='<%# Bind("DestinationID") %>' />
                </td>
                <td>
                    <asp:TextBox ID="StartDateTextBox" runat="server" Text='<%# Bind("StartDate") %>' />
                </td>
                <td>
                    <asp:TextBox ID="EndDateTextBox" runat="server" Text='<%# Bind("EndDate") %>' />
                </td>
                <td>
                    <asp:TextBox ID="PriceTextBox" runat="server" Text='<%# Bind("Price") %>' />
                </td>
                <td>
                    <asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
                </td>
                <td>
                    <asp:TextBox ID="TransportationIDTextBox" runat="server" Text='<%# Bind("TransportationID") %>' />
                </td>
                <td>
                    <asp:TextBox ID="BoardIDTextBox" runat="server" Text='<%# Bind("BoardID") %>' />
                </td>
                <td>
                    <asp:TextBox ID="ReservationsTextBox" runat="server" Text='<%# Bind("Reservations") %>' />
                </td>
                <td>
                    <asp:TextBox ID="FacilitiesTextBox" runat="server" Text='<%# Bind("Facilities") %>' />
                </td>
            </tr>
        </InsertItemTemplate>
        <ItemTemplate>
            <tr style="background-color: #DCDCDC; color: #000000;">
                <td>
                    <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
                    <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                </td>
                <td>
                    <asp:Label ID="TourIDLabel" runat="server" Text='<%# Eval("TourID") %>' />
                </td>
                <td>
                    <asp:Label ID="DestinationIDLabel" runat="server" Text='<%# Eval("Destination.DestinationName") %>' />
                </td>
                <td>
                    <asp:Label ID="StartDateLabel" runat="server" Text='<%# Eval("StartDate") %>' />
                </td>
                <td>
                    <asp:Label ID="EndDateLabel" runat="server" Text='<%# Eval("EndDate") %>' />
                </td>
                <td>
                    <asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>' />
                </td>
                <td>
                    <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
                </td>
                <td>
                    <asp:Label ID="TransportationIDLabel" runat="server" Text='<%# Eval("Transportation.TransportName") %>' />
                </td>
                <td>
                    <asp:Label ID="BoardIDLabel" runat="server" Text='<%# Eval("Board.BoardName") %>' />
                </td>
                <td>
                    <asp:Label ID="ReservationsLabel" runat="server" Text='<%# Eval("Reservations") %>' />
                </td>
                <td>
                    <asp:ListBox ID="FacilitiesLabel" runat="server" DataSource='<%# Eval("Facilities") %>'
                     DataTextField="FacilityName" DataValueField="FacilityID"/>
                </td>
            </tr>
        </ItemTemplate>
        <LayoutTemplate>
            <table runat="server">
                <tr runat="server">
                    <td runat="server">
                        <table id="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF;
                               border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px;
                               font-family: Verdana, Arial, Helvetica, sans-serif;">
                            <tr runat="server" style="background-color: #DCDCDC; color: #000000;">
                                <th runat="server">
                                </th>
                                <th runat="server">
                                    TourID
                                </th>
                                <th runat="server">
                                    DestinationID
                                </th>
                                <th runat="server">
                                    StartDate
                                </th>
                                <th runat="server">
                                    EndDate
                                </th>
                                <th runat="server">
                                    Price
                                </th>
                                <th runat="server">
                                    Description
                                </th>
                                <th runat="server">
                                    TransportationID
                                </th>
                                <th runat="server">
                                    BoardID
                                </th>
                                <th runat="server">
                                    Facilities
                                </th>
                            </tr>
                            <tr id="itemPlaceholder" runat="server">
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr runat="server">
                    <td runat="server" style="text-align: center; background-color: #CCCCCC; font-family: Verdana, Arial, Helvetica, sans-serif;
                        color: #000000;">
                        <asp:DataPager ID="DataPager1" runat="server">
                            <Fields>
                                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" />
                            </Fields>
                        </asp:DataPager>
                    </td>
                </tr>
            </table>
        </LayoutTemplate>
        <SelectedItemTemplate>
            <tr style="background-color: #008A8C; font-weight: bold; color: #FFFFFF;">
                <td>
                    <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
                    <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                </td>
                <td>
                    <asp:Label ID="TourIDLabel" runat="server" Text='<%# Eval("TourID") %>' />
                </td>
                <td>
                    <asp:Label ID="DestinationIDLabel" runat="server" Text='<%# Eval("DestinationID") %>' />
                </td>
                <td>
                    <asp:Label ID="StartDateLabel" runat="server" Text='<%# Eval("StartDate") %>' />
                </td>
                <td>
                    <asp:Label ID="EndDateLabel" runat="server" Text='<%# Eval("EndDate") %>' />
                </td>
                <td>
                    <asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>' />
                </td>
                <td>
                    <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
                </td>
                <td>
                    <asp:Label ID="TransportationIDLabel" runat="server" Text='<%# Eval("TransportationID") %>' />
                </td>
                <td>
                    <asp:Label ID="BoardIDLabel" runat="server" Text='<%# Eval("BoardID") %>' />
                </td>
                <td>
                    <asp:Label ID="BoardLabel" runat="server" Text='<%# Eval("Board") %>' />
                </td>
                <td>
                    <asp:Label ID="DestinationLabel" runat="server" Text='<%# Eval("Destination") %>' />
                </td>
                <td>
                    <asp:Label ID="ReservationsLabel" runat="server" Text='<%# Eval("Reservations") %>' />
                </td>
                <td>
                    <asp:Label ID="TransportationLabel" runat="server" Text='<%# Eval("Transportation") %>' />
                </td>
                <td>
                    <asp:Label ID="FacilitiesLabel" runat="server" Text='<%# Eval("Facilities") %>' />
                </td>
            </tr>
        </SelectedItemTemplate>
    </asp:ListView>
    <asp:EntityDataSource ID="TravelAgencyDateSource" runat="server" ConnectionString="name=TravelAgencyDatabaseEntities"
                          DefaultContainerName="TravelAgencyDatabaseEntities" EnableDelete="True" EnableFlattening="False"
                          EnableInsert="True" EnableUpdate="True" EntitySetName="Tours" Include="Destination, Transportation, Facilities, Board">
    </asp:EntityDataSource>
</asp:Content>
